using System;
namespace CarolLib.Extension
{
    public static class DateTimeExtension
    {
        private static readonly DateTime MinDate = new DateTime(1900, 1, 1);
        private static readonly DateTime MaxDate = new DateTime(9999, 12, 31, 23, 59, 59, 999);

        public static bool IsValid(this DateTime target)
        {
            return (target >= MinDate) && (target <= MaxDate);
        }

        public static int ToTicket(this DateTime target)
        {
            DateTime baseTime = new DateTime(1970, 1, 1);
            TimeSpan ts = target.ToUniversalTime() - baseTime.ToUniversalTime();
            return Convert.ToInt32(ts.TotalSeconds);
        }
    }
}